/*
 * Copyright (c) 2006 - 2022, webrx.cn All rights reserved.
 *
 */
package cn.demo;

import java.util.stream.Stream;

/**
 * <p>Project: app2022 - Stream5
 * <p>Powered by webrx On 2022-01-26 14:18:16
 *
 * @author webrx [webrx@126.com]
 * @version 1.0
 * @since 17
 */
public class Stream5 {
    public static void main(String[] args) {
        //Stream<Student> 流
        var is = Stream.of(new Student(1, "李四", "男", 18), new Student(2, "张三", "男", 28), new Student(3, "王五", "男", 38), new Student(1, "李四", "男", 18), new Student(4, "李丽", "女", 25));
        //is.distinct().forEach(System.out::println);

        //求出男生的年龄总和
        //System.out.println(is.filter(e -> "男".equals(e.getGender())).mapToInt((e) -> e.getAge()).sum());

        //ystem.out.println(is.filter(e -> "男".equals(e.getGender())).map(Student::getAge).reduce(0, Integer::sum));
        //System.out.println(is.filter(e -> "男".equals(e.getGender())).map(Student::getAge).mapToInt(e -> e).sum());

        //Stream<Integer>  18,28,38,18  18,28  46,38  84,18

    }
}
